package com.smyk.btchina.base

import androidx.viewbinding.ViewBinding
import com.smyk.btchina.net.api.NetStatus


/**
 * @des MVVM 的Activity
 * @date 2021/7/2
 * @author sam
 */
abstract class BaseMvvmActivity<VB : ViewBinding, VM : BaseViewModel> : BaseActivity<VB>() {

    protected val mViewModel: VM by lazy { getViewModel() }

    abstract fun getViewModel(): VM

    override fun initData() {
        super.initData()
        mViewModel.netStatus.observe(this) {
            when (it) {
                NetStatus.LOADING -> {
                    showLoading()
                }
                NetStatus.COMPLETE -> {
                    dismissLoading()
                }
                else -> {

                }
            }
        }
    }

}